<?php
	$title_meta = '搜索 | ';
	include ("header.php");
?>

<div class="works index">
	<ul>
		<div class="clear"></div>
	</ul>
</div>

<script type="text/javascript">
	function GetArgsFromHref(sHref, sArgName){
		   	var args    = sHref.split("?");
		    var retval = "";
		    if(args[0] == sHref) /*参数为空*/
		    {
		        return retval; /*无需做任何处理*/
		    }  
		    var str = args[1];
		    args = str.split("&");
		    for(var i = 0; i < args.length; i ++)
		    {
		        str = args[i];
		        var arg = str.split("=");
		        if(arg.length <= 1) continue;
		        if(arg[0] == sArgName) retval = arg[1]; 
		    }
	    	return retval;
		}
		
	var postKey = GetArgsFromHref(window.location.href,'key');
	
	 $(document).ready(function(){
        mainliWidth();
        $(window).resize(function(){
          mainliWidth();
        });
      
         function mainliWidth(){
        	var liw = $(".index .hover").width();
        	var lih = liw * 0.75;
        	$(".index>ul>li").height(lih);
	        $(".index .mask").height(lih);
	        $(".index .mask_text").height(lih);
	        $(".index .hover>a").width(liw-3);
	        $(".index .hover>a").height(lih);
        }
    });
    
		$(document).ready(function(){
			
			if (postKey) {

        		$.ajax({
        			type:"post",
        			url:"./app/index.php?m=index&a=search",
        			data:{'key':postKey},
        			success:function(ret){
        				var html = "";
        				var i=0;
        				for(var i in ret){
        					html+="<li class='hover' style='background: url(./app/data/upload/"+ret[i].cover+") 0% 0% / 100% 100% no-repeat;'><a href='case.php?id="+ret[i].id+"'></a><div class='mask'></div><a href='case.php?id="+ret[i].id+"' class='mask_text'><h1> "+ret[i].post_brand+" </h1><h2>"+ret[i].post_title+"</h2><p></p></a></li>";
        				}
        				$(".index>ul").prepend(html);
        				var liw = $(".index .hover").width();
        	        	var lih = liw * 0.75;
        	        	$(".index>ul>li").height(lih);
        		        $(".index .mask").height(lih);
        		        $(".index .mask_text").height(lih);
        		        $(".index .hover>a").width(liw-3);
        		        $(".index .hover>a").height(lih);
        			}
        		});
			}
		});
</script>

<?php
	include ("footer.php");
?>